package com.jt.controller;

import com.jt.pojo.ItemList;
import com.jt.pojo.Query;
import com.jt.service.ItemListService;
import com.jt.vo.ItemVO;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/item")
public class ItemlistController {
    @Autowired
    private ItemListService itemListService ;

    @RequestMapping("/findItemList")    //查数据库里全部商品
    public List<ItemList> findItemList(){
        List<ItemList> list = itemListService.selectPageList();
        return list;
    }
    @RequestMapping("/recommendList")   //查数据库里Hot-ID=1的数据
    public List<ItemList> recommendList(){
        List<ItemList> recommendList = itemListService.selectrecommendList();
//        System.out.println("牛啊");
        return recommendList;
    }
    @RequestMapping("/HotList")         //查数据库内Hot_id=2的数据
    public List<ItemList> HotList(){
        List<ItemList> HotList = itemListService.selectHotList();
        return HotList;
    }

    @RequestMapping("/saveItem")
    public SysResult addItem(@RequestBody ItemVO itemVO){
        itemListService.saveItem(itemVO);
        return SysResult.success();
    }

    @RequestMapping("/toQuery")
    public List<ItemList> toQuery(@RequestBody Query query){
        List<ItemList> list=itemListService.toQuery(query.getQuery());
        return list;
    }
}
